package org.rapan;

import org.rapan.jpa.Consultant;

import com.vaadin.ui.VerticalLayout;

@SuppressWarnings("serial")
public class SearchConsultantLayout extends VerticalLayout {
	public SearchConsultantLayout() {
		super();
		addSearchLayout();
	}

	public void reset() {

		addSearchLayout();
	}

	private void addSearchLayout() {
		removeAllComponents();
		SearchLayout search = new SearchLayout() {

			@Override
			public void consultantSelected(Consultant c) {
				addProfileLayout(c);
			}
		};
		addComponent(search);

	}

	protected void addProfileLayout(Consultant c) {
		removeAllComponents();
		ProfileLayout profile = new ProfileLayout(c, true) {

			@Override
			public void editButtonSelected(Consultant c) {
				addEditLayout(c);
			}
		};
		addComponent(profile);
	}

	protected void addEditLayout(Consultant c) {
		removeAllComponents();
		ConsultantForm conForm = new ConsultantForm(c) {

			@Override
			public void successfulEdit() {
				reset();
			}
		};
		addComponent(conForm);

	}

}
